package com.flashcash.kotlin.trace

import android.os.SystemClock
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.*

/**
 * @作者:XLEO
 * @创建日期: 2017/9/1 14:34
 * @描述:${TODO}
 *
 * @更新者:${Author}$
 * @更新时间:${Date}$
 * @更新描述:${TODO}
 * @下一步：
 */

open class LocalTextWatcher(val view: TextView, val name: String) : TextWatcher {
    var old: CharSequence? = null
    var startTime: Long = 0
    override fun afterTextChanged(s: Editable?) {
    }

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
        old = view.text
        startTime = SystemClock.elapsedRealtime()
    }

    override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
    }

}

class LocalOnFocusChangeListener(val view: View, val name: String, val l: View.OnFocusChangeListener?, val scrollView: Int) : View.OnFocusChangeListener {
    //    private val softListener: SoftSpanPopEditText = SoftSpanPopEditText()
    private var oldText: String? = null
    private var startTime: Long = 0L
    private var newText: String? = null

    override fun onFocusChange(v: View?, hasFocus: Boolean) {
        l?.onFocusChange(v, hasFocus)
        if (hasFocus) {
            startTime = SystemClock.elapsedRealtime()
            if (v is EditText) {
                oldText = v.text.toString()
            }
//            softListener.register(view, scrollView)
        } else {
            if (v is EditText) {
                newText = v.text.toString()
            }
        }
    }

}

open class LocalOnClickListener(val name: String?, val l: View.OnClickListener?) : View.OnClickListener {
    override fun onClick(v: View?) {
        l?.onClick(v)
    }

}